package com.sourcetrip.my;


import com.sourcetrip.my.inter.Stack;

/**
 * @author: ZhouBert
 * @date: 2020/12/14
 * @description: 通过 ArrayList 实现栈的接口
 * easy
 */
public class StackByArrayListV0<E> implements Stack<E> {
	private ArrayListV0<E> list = new ArrayListV0();

	@Override
	public void clear() {
		list.clear();
	}

	@Override
	public int size() {
		return list.size();
	}

	@Override
	public boolean isEmpty() {
		return list.isEmpty();
	}

	@Override
	public void push(E element) {
		list.add(element);
	}

	@Override
	public E pop() {
		return list.remove(size() - 1);
	}

	@Override
	public E peek() {
		E e = list.get(size() - 1);
		return e;
	}
}
